package com.delu.controller;

import com.delu.data.Result;
import com.delu.em.ResultEnum;
import com.delu.entity.CarBrand;
import com.delu.entity.PayRank;
import com.delu.mapper.PayRanksMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("payRank")
@Api("充值管理")
public class PayRankController {
    @Resource
    private PayRanksMapper payRanksMapper;

    @GetMapping
    @ApiOperation("消费记录查询")
    @ApiImplicitParam(name = "id",value = "充值ID",required = true,paramType = "query")
    public Result selectPayRank(@RequestParam("id")Long id){
        System.out.println("充值信息" + id);
        List<PayRank> payRankList = payRanksMapper.selectPayRank(id);
        return Result.response(ResultEnum.SUCCESS).setData(payRankList);
    }

    @PostMapping
    @ApiOperation("用户ID查询")
    @ApiImplicitParam(name = "userId",value = "用户ID",required = true,paramType = "query")
    public Result selectUserIdPayRank(@RequestParam("userId")Long userId){
        System.out.println("充值信息用户" + userId);
        List<PayRank> payRankLists = payRanksMapper.selectUserIdPayRank(userId);
        return Result.response(ResultEnum.SUCCESS).setData(payRankLists);
    }
    @PostMapping
    @ApiOperation("消费记录增加")
    @ApiImplicitParam(name = "payRank",value = "消费记录实体类",required = true,paramType = "body")
    public Result insertCarBrand(@RequestBody PayRank payRank){
        Integer i = payRanksMapper.insert(payRank);
        System.out.println("消费信息" + payRank);
        return Result.response(ResultEnum.SUCCESS).setData(i);
    }

    @PutMapping
    @ApiOperation("消费记录修改")
    @ApiImplicitParam(name = "payRank",value = "消费记录实体类",required = true,paramType = "body")
    public Result updateCarBrand(@RequestBody PayRank payRank){
        Integer i = payRanksMapper.updateById(payRank);
        System.out.println("消费信息" + payRank);
        return Result.response(ResultEnum.SUCCESS).setData(i);
    }
}
